/*************************************************************************
	> File Name: 110.平衡二叉树.c
	> Author: Maureen 
	> Mail: Maureen@qq.com 
	> Created Time: 三  9/15 12:43:28 2021
 ************************************************************************/

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */

int height(struct TreeNode *root) {
    if (root == NULL) {
        return 0;
    } 
    return fmax(height(root->left), height(root->right)) + 1;
}


bool isBalanced(struct TreeNode* root){
    if (root == NULL) return true;
    return fabs(height(root->left) - height(root->right)) <= 1 && isBalanced(root->left) && isBalanced(root->right);
}
